using System;
using System.Drawing;

using SdlDotNet.Graphics;

using Game.Data;
using Game.Utils;
using Game.Input;
using Game.Output;

namespace Game.World
{
	public class CCountry
	{
		private const int	ADDITIONAL_SURFACE_HEIGHT = 100;
		private const int	STD_TILE_WIDTH = 64;
		private const int	STD_TILE_HEIGHT = 32;
		
		private CWorld	m_world;
		
		private Surface	m_surface;		
		private Point	m_position;
		private Size	m_mapSize;
		private Point	m_origin;
		private string	m_name;
		
		public CCountry(string p_name, CWorld p_world)
		{
			CConsole.ReportClassInit(System.Reflection.MethodInfo.GetCurrentMethod().DeclaringType.Name);
			CConsole.ReportParam("p_name",  p_name);
			CConsole.ReportParam("p_world.Name",  p_world.Name);
			
			m_name	= p_name;
			m_world	= p_world;
			
			Initialize();
		}
		
		private void Initialize()
		{
			m_mapSize = new Size(
				Convert.ToInt32(CData.Settings.Get("MAP_SIZE_X")),
				Convert.ToInt32(CData.Settings.Get("MAP_SIZE_Y"))
			);
				
			Size size = new Size();
			
			// needs to be checked! width/height correctly inserted?
			{
			size.Width = STD_TILE_WIDTH  + (m_mapSize.Height - 1) *  STD_TILE_WIDTH      +
					(m_mapSize.Width - 1) *  STD_TILE_WIDTH;
			
			size.Height = STD_TILE_HEIGHT + (m_mapSize.Width - 1)  * (STD_TILE_WIDTH / 2) +
					(m_mapSize.Width - 1) * (STD_TILE_WIDTH / 2) + ADDITIONAL_SURFACE_HEIGHT;
			}
			
			CSurfaceFactory.CreateSurface(out m_surface, size);
			
			m_origin = new Point(m_mapSize.Height * 32, 0);
			
			m_position = new Point(0,0);
		}
		
		public void Render(ref Surface p_surface)
		{
			p_surface.Blit(m_surface, m_position);
		}
		
		#region properties
		
		public string Name
		{
			get {
				return m_name;
			}
		}
		
		public Point Position
		{
			get {
				return m_position;
			}
		}
		
		public Point Origin
		{
			get {
				return m_origin;
			}
		}
		
		public Surface Surface
		{
			get {
				return m_surface;
			}
		}
		
		public Size MapSize
		{
			get {
				return m_mapSize;
			}
		}
		
		#endregion
		
	}
}
